<?php
$text=$item->innertext;

$activeMenu=$text;
$inactiveMenu=$text;

$subMenu="";

$domMenu=str_get_html($text);

$itemMenuArray=$domMenu->find("[com]");

foreach ($itemMenuArray as $itemMenu)
    {
    if ($itemMenu->com == "menu_active")
        {
        $activeMenu=$itemMenu->outertext;
        }

    if ($itemMenu->com == "menu_inactive")
        {
        $inactiveMenu=$itemMenu->outertext;
        }
        
        
        
        

    if ($itemMenu->com == "submenu2")
        {
        $subMenu=$itemMenu->outertext;

        $subMenuOrginal=$subMenu;

        $subMenuInnerBody=$itemMenu->innertext;
        $subMenuInnerBodyOrginal=$subMenuInnerBody;
        }
    
    
    
    
    
    }


// falls Submenu vorhanden ist

if ($subMenu !== "")
    {

    $subMenuInnerBody='<?php
  $sqlSubMenu       ="SELECT * FROM page WHERE menu_active = 1 
            AND item_parent_id = \'".$dataquery_menu["id"]."\' ORDER BY item_order";  
            
  foreach(data::getQuery($sqlSubMenu) as $dataquery_submenu) {

  
?>
'
        . $subMenuInnerBody . '<?php } ?>';

    $subMenuInnerBody=
        str_replace('[submenu.url]', '<?php echo config::$baseUrl.$dataquery_submenu["_url"];?>', $subMenuInnerBody);
    $subMenuInnerBody=
        str_replace('[submenu.title]', '<?php echo config::$baseUrl.$dataquery_submenu["title"];?>', $subMenuInnerBody);


        
    $activeMenu = str_ireplace($subMenuInnerBodyOrginal, $subMenuInnerBody, $activeMenu);
    $inactiveMenu = str_ireplace($subMenuInnerBodyOrginal, $subMenuInnerBody, $inactiveMenu);
        
        
        
        
        //echo $activeMenu;
        
        
    /* $domMenu=str_get_html($subMenu);
   
     
     
     $itemSubMenuArray=$domSubMenu->find("[com]");
   
               foreach ($itemMenuArray as $itemMenu)
                   {
     
     
               
                       if ($itemMenu->com == "active") {
                           $activeMenu = $itemMenu->outertext;
                       }
                       
                       
                       if ($itemMenu->com == "inactive") {
                           $inactiveMenu = $itemMenu->outertext;
                       }
     
     
                       if ($itemMenu->com == "submenu2") {
                           $subMenu = $itemMenu->outertext;
                           $subMenuOrginal = $subMenu;
                       }
                   
                   
                   
                   }    */

    }


//$html=$dom->save();


//  $content = "aktives menu $acitveMenu inaktivesmenu $inactiveMenu";


/*$content = str_replace('[menu.url]', '<?php echo config::$baseUrl.$dataquery_menu["_url"];?>', $content);                                                 
$content = str_replace('[menu.title]', '<?php echo config::$baseUrl.$dataquery_menu["title"];?>', $content);                                                 
  */


// echo $activeMenu;

$body=str_ireplace("[content_active_menu]", $activeMenu, $body);
$body=str_ireplace("[content_inactive_menu]", $inactiveMenu, $body);

$body=str_replace('[menu.url]', '<?php echo config::$baseUrl.$dataquery_menu["_url"];?>', $body);
$body=str_replace('[menu.title]', '<?php echo config::$baseUrl.$dataquery_menu["title"];?>', $body);
?>